package com.sqx.modules.task.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.task.entity.TbDailyTasks;
import com.sqx.modules.task.entity.TbUserTask;
import com.sqx.modules.task.service.TbUserTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description：TODO
 * @author： qiao
 * @create： 2024/7/22 15:23
 */
@RestController
@RequestMapping("/app/tbUserTask/")
@Api(value = "用户任务-用户端", tags = {"用户任务-用户端"})
public class TbUserTaskController {

    @Autowired
    private TbUserTaskService tbUserTaskService;

    @Login
    @GetMapping(value = "getTbUserTaskList")
    @ApiOperation("获取用户的任务列表及完成情况")
    public Result getTbUserTaskList(@ApiParam("页码") Integer pageNum,
                                    @ApiParam("条数")Integer pageSize,
                                    @ApiParam("用户每日任务实体")TbUserTask tbUserTask,
                                    @ApiParam("用户id")@RequestAttribute("userId")Long userId) {
        tbUserTask.setUserId(userId);
        return tbUserTaskService.getTbUserTaskList(pageNum, pageSize, tbUserTask);
    }

    @Login
    @GetMapping(value = "selectTbOrders")
    @ApiOperation("获取用户卖出的订单并创建每日任务")
    public Result selectTbOrders(@ApiParam("用户id")@RequestAttribute("userId")Long userId,
                                 @ApiParam("用户每日任务id")Long taskId) {
        return tbUserTaskService.selectTbOrders(userId, taskId);
    }

    @GetMapping(value = "selectAllList")
    @ApiOperation("获取所有的任务列表")
    public Result selectAllList(@ApiParam("页码")Integer pageNum, @ApiParam("条数")Integer pageSize, @ApiParam("每日任务实体")TbDailyTasks tbDailyTasks) {
        return tbUserTaskService.selectAllList(pageNum,pageSize,tbDailyTasks);
    }
}
